package com.youxin.busfoundation.common.es;

import com.youxin.busfoundation.common.es.bean.CompanyBaseBean;
import com.youxin.busfoundation.common.es.bean.CompanyIndexBean;
import com.youxin.busfoundation.common.es.bean.ContactBean;
import com.youxin.foundation.lang.BaseException;
import com.youxin.foundation.utils.JsonUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @desc ES联系人操作
 * @author Kris.wang
 * @date 2017-12-25
 */
public class ContactHandle extends BaseHandle{

    // Index索引类型
    private static final String TYPE  = "sls_contact";

    /**
     * @desc 获取联系人文档
     * @param id
     * @return
     * @throws Exception
     */
    public ContactBean getContactIndex(String id) throws Exception
    {
        ContactBean bean = JsonUtils.stringToFasterxmlObject(getIndex(TYPE, "business", id), ContactBean.class);
        if (bean==null) {
            bean = JsonUtils.stringToFasterxmlObject(getIndex(TYPE, "spider", id), ContactBean.class);
        }
        return bean;
    }

}
